package com.wyj.wuliwuli.controller;

import com.wyj.wuliwuli.common.AjaxRequest;
import com.wyj.wuliwuli.common.AjaxResult;
import com.wyj.wuliwuli.common.PageParam;
import com.wyj.wuliwuli.entity.WuliVideo;
import com.wyj.wuliwuli.entity.WuliVideoComment;
import com.wyj.wuliwuli.service.WuliVideoCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Api(tags = "评论")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/wuli-video-comment")
public class WuliVideoCommentController {

    private final WuliVideoCommentService wuliVideoCommentService;

    @ApiOperation(value = "分页查询")
    @PostMapping("/page")
    public AjaxResult page(@RequestBody AjaxRequest<PageParam> ajaxRequest) {
        return wuliVideoCommentService.page(ajaxRequest);
    }

    @ApiOperation(value = "根据id查询")
    @GetMapping("/{id}")
    public AjaxResult getById(@PathVariable Long id) {
        return wuliVideoCommentService.getById(id);
    }

    @ApiOperation(value = "根据视频id查询评论")
    @GetMapping("/video/{video_id}")
    public AjaxResult getByVideoId(@PathVariable Long video_id) {
        return wuliVideoCommentService.getByVideoId(video_id);
    }

    @ApiOperation(value = "保存")
    @PostMapping("/save")
    public AjaxResult save(@RequestBody AjaxRequest<WuliVideoComment> ajaxRequest) {
        return wuliVideoCommentService.save(ajaxRequest);
    }

    @ApiOperation(value = "根据id删除")
    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Long id) {
        return wuliVideoCommentService.deleteById(id);
    }



}
